﻿@using Newtouch.Infrastructure;
@{
    ViewBag.Title = "";
    Layout = "~/Views/Shared/_Form.cshtml";
}
<div class="rows">
    <div class="panel panel-default">
        <table class="form">
            <tr>
                <th class="formTitle">开始日期：</th>
                <td class="formValue">
                    <input id="kssj" type="text" class="form-control input-wdatepicker form-an"
                           onclick="WdatePicker({ dateFmt: 'yyyy-MM-dd'})" value="@(DateTime.Now.ToString("yyyy-MM-01"))" />
                </td>
                <th class="formTitle">结束日期：</th>
                <td class="formValue">
                    <input id="jssj" type="text" class="form-control input-wdatepicker form-an"
                           onclick="WdatePicker({ dateFmt: 'yyyy-MM-dd'})" value="@(DateTime.Now.ToString("yyyy-MM-dd"))" />
                </td>
                <th class="formTitle">报表类型：</th>
                <td class="formValue" style="width: 170px">
                    @Html.DropDownList("sel_rptype", EnumRportType.zgmzjz.ToDescSelectList(), new { @class = "form-control form-an" })

                </td>
                <th class="formTitle">预留金：</th>
                <td class="formValue">
                    <div class="row">
                        <div class="col-md-3">
                            <input type="text" class="form-control" style="width:40px" id="txtylj" value="10" />
                        </div>

                        <div class="col-md-3" style="text-align:left;">
                            <span>%</span>
                        </div>
                    </div>
                </td>
                <td class="formValue" style="padding-left:20px;">
                    <input type="button" id="btn_search" onclick="submit();" class="btn btn-primary btn-md" value="查询" style="width:55px" />
                </td>
                <td class="formValue"></td>
            </tr>
        </table>
    </div>
</div>

<div class="ui-layout" id="layout" style="height:100%;width:100%;">
    <iframe class="ui-layout-center" style="width:100%;" id="iframerightiframerightiframerightttt" name="iframerightiframerightiframerightttt"
            scrolling="auto" allowtransparency="true" frameborder="0"></iframe>
</div>
<script type="text/javascript">
    var reportServerHOST = '@(ViewBag.ReportServerHOST)';
    var orgId = '@(ViewBag.OrgId)';
    var isHospAdministrator = '@(ViewBag.IsHospAdministrator)';
    var curUserCode = '@(ViewBag.CurUserCode)';

    //var uri = 'ReportServer/Pages/ReportViewer.aspx?%2fHIS.Report.1%2fChongqing%e5%8c%bb%e4%bf%9d%e7%bb%93%e7%ae%97%e7%94%b3%e6%8a%a5%e8%a1%a8&rs:Command=Render';
    //var mzjzuri = 'ReportServer/Pages/ReportViewer.aspx?%2fHIS.Report.1%2fChongqing%e8%81%8c%e5%b7%a5%e5%b1%85%e6%b0%91%e8%b4%b9%e7%94%a8%e7%94%b3%e8%af%b7%e8%a1%a8(%e6%b0%91%e6%94%bf%e6%95%91%e5%8a%a9)&rs:Command=Render';

    var uri = 'ReportServer/Pages/ReportViewer.aspx?%2fHIS.Report.1%2fChongqingNew%e5%8c%bb%e4%bf%9d%e7%bb%93%e7%ae%97%e7%94%b3%e6%8a%a5%e8%a1%a8&rs:Command=Render';
    var mzjzuri = 'ReportServer/Pages/ReportViewer.aspx?%2fHIS.Report.1%2fChongqingNew%e8%81%8c%e5%b7%a5%e5%b1%85%e6%b0%91%e8%b4%b9%e7%94%a8%e7%94%b3%e8%af%b7%e8%a1%a8(%e6%b0%91%e6%94%bf%e6%95%91%e5%8a%a9)&rs:Command=Render';
    var yduri = 'ReportServer/Pages/ReportViewer.aspx?%2fHIS.Report.1%2fChongqingNew医保结算申报表(异地)&rs:Command=Render';
    function submit() {

        if ($('#kssj').val().length == 0) {
            $.modalAlert("缺少开始时间", "error");
            return;
        }
        if ($('#jssj').val().length == 0) {
            $.modalAlert("缺少结束时间", "error");
            return;
        }
        if ($('#kssj').val() > $('#jssj').val()) {
            $.modalAlert("开始时间不能大于结束时间", "error");
            return;
        }
        var patrn = /^\+?[1-9][0-9]*$/;
        var yljv = $('#txtylj').val();
        if (patrn.exec(yljv) == null || yljv == "") {
            $.modalAlert("预留金只能输入正整数", "error");
            return;
        } 

        var url = getUrl();
        var type = $('#sel_rptype').val();
        var dybh = null;
        
        if (type==1||type==2) {

            url += "&kssj=" + $('#kssj').val();
            url += "&jssj=" + $.getDate({ date: $('#jssj').val() }) + ' 23:59:59';
            url += "&cblb=" + type;
        }
        else
        {
            if (type == 6 || type == 7) {
                dybh = 1;
            }
            if (type==3||type==6) {
                type = 1;
            }
            else if (type == 4 || type == 7) {
                type = 2;
            } else {
                type = 3;
            }


        url += "&kssj=" + $('#kssj').val();
        url += "&jssj=" + $.getDate({ date: $('#jssj').val() }) + ' 23:59:59';
        url += "&ylj=" + $('#txtylj').val();
        url += "&cblb=" + type;
            if(dybh){
                url += "&dybh=" + dybh;
            }
        }
        setTimeout("$.loading(true, '正在请求报表页面...');", 10);

        $("#iframerightiframerightiframerightttt").attr('src', url);


    }
    $("#iframerightiframerightiframerightttt").load(function () {
        $.loading(false);
    });

    $(function () {
        var h = $(window).height() - 55
        $('#layout iframe').css('height', h);


        setTimeout(function () { submit(); }, 100);
    });

    function getUrl() {
        if (uri.StartWith('/')) {
            uri = uri.substr(1);
        }
        var reporttype = $('#sel_rptype').val();
        var srcUrl = uri;
        if (reporttype == 1 || reporttype==2) {
            srcUrl = mzjzuri;
        }
        if (reporttype == 6 || reporttype == 7)
        {
            srcUrl = yduri;
        }
  
        srcUrl = reportServerHOST + srcUrl;

        //获取自定义样式
        if (true) {
            if (srcUrl.indexOf('&rc:') == -1) {
                srcUrl += "&rc:Stylesheet=MyStyleSheet";
            }
        }
        if (true) {
            if (srcUrl.indexOf('&rs:') == -1) {
                srcUrl += "&rs:";
            }
            else {
                srcUrl += "&";
            }
            srcUrl += "orgId=";
            srcUrl += orgId;
        }
        return srcUrl;
    }

</script>
